 package net.go176.backpack.core.mcp9_0;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Collection;

 import net.go176.backpack.core.DataType;
 import net.go176.backpack.core.MyDataHandler;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.nbt.CompressedStreamTools;
 import net.minecraft.nbt.NBTBase;
 import net.minecraft.nbt.NBTTagCompound;
 import net.minecraft.nbt.NBTTagInt;
 import net.go176.backpack.Backpack;
 import net.go176.backpack.util.NMSUtil;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.Player;
 import thaumcraft.api.research.ResearchCategories;
 import thaumcraft.api.research.ResearchCategoryList;
 import thaumcraft.api.research.ResearchItem;
 import thaumcraft.common.Thaumcraft;
 import thaumcraft.common.lib.research.ResearchManager;
 
 public class ThaumcraftHandler
   extends MyDataHandler {
   public ThaumcraftHandler(Backpack plugin) {
     super(plugin);
   }
 
   
   public DataType getDataType() {
     return DataType.THAUMCRAFT;
   }
 
   
   public void saveData(File file, Player player) throws IOException {
     if (!this.cfgMan.multi_Thaumcraft_Knowledge)
       return; 
     String playerName = player.getName();
     File filetmp = new File(String.valueOf(file.getPath()) + ".tmp");
     EntityPlayer nms_player = (EntityPlayer)NMSUtil.getNMSEntity((Entity)player);
     NBTTagCompound nbt = new NBTTagCompound();
     ResearchManager.saveResearchNBT(nbt, nms_player);
     ResearchManager.saveAspectNBT(nbt, nms_player);
     ResearchManager.saveScannedNBT(nbt, nms_player);
     if (Thaumcraft.instance.runicEventHandler.runicCharge.containsKey(Integer.valueOf(player.getEntityId())))
       nbt.func_74782_a("Thaumcraft.shielding", (NBTBase)new NBTTagInt(((Integer)Thaumcraft.instance.runicEventHandler.runicCharge.get(Integer.valueOf(player.getEntityId()))).intValue())); 
     nbt.func_74782_a("Thaumcraft.eldritch", (NBTBase)new NBTTagInt(Thaumcraft.proxy.getPlayerKnowledge().getWarpPerm(playerName)));
     nbt.func_74782_a("Thaumcraft.eldritch.temp", (NBTBase)new NBTTagInt(Thaumcraft.proxy.getPlayerKnowledge().getWarpTemp(playerName)));
     nbt.func_74782_a("Thaumcraft.eldritch.sticky", (NBTBase)new NBTTagInt(Thaumcraft.proxy.getPlayerKnowledge().getWarpSticky(playerName)));
     nbt.func_74782_a("Thaumcraft.eldritch.counter", (NBTBase)new NBTTagInt(Thaumcraft.proxy.getPlayerKnowledge().getWarpCounter(playerName)));
     FileOutputStream output = new FileOutputStream(filetmp);
     try {
       CompressedStreamTools.func_74799_a(nbt, output);
     } finally {
       output.close();
     } 
     if (file.exists())
       file.delete(); 
     filetmp.renameTo(file);
   }
 
   
   public void loadData(File file, Player player) throws IOException {
     if (!this.cfgMan.multi_Thaumcraft_Knowledge)
       return; 
     String playerName = player.getName();
     EntityPlayer nms_player = (EntityPlayer)NMSUtil.getNMSEntity((Entity)player);
     Thaumcraft.proxy.getPlayerKnowledge().wipePlayerKnowledge(playerName);
     if (file.exists())
       ResearchManager.loadPlayerData(nms_player, file, null, false); 
     Collection<ResearchCategoryList> rc = ResearchCategories.researchCategories.values();
     for (ResearchCategoryList cat : rc) {
       Collection<ResearchItem> res = cat.research.values();
       for (ResearchItem ri : res) {
         if (ri.isAutoUnlock())
           Thaumcraft.proxy.getResearchManager().completeResearch(nms_player, ri.key); 
       } 
     } 
   }
 }


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpack\core\mcp9_0\ThaumcraftHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */